﻿// Decompiled with JetBrains decompiler
// Type: MCM.LightInject.ConcreteTypeExtractor
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;

#nullable disable
namespace MCM.LightInject
{
  [ExcludeFromCodeCoverage]
  internal class ConcreteTypeExtractor : ITypeExtractor
  {
    private static readonly List<Type> InternalTypes = new List<Type>();

    static ConcreteTypeExtractor()
    {
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ConstructorDependency));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PropertyDependency));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ThreadSafeDictionary<,>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (Scope));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerContainerLifetime));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerScopeLifetime));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ServiceRegistration));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (DecoratorRegistration));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ServiceRequest));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (Registration));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ServiceContainer));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ConstructionInfo));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (AssemblyLoader));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (TypeConstructionInfoBuilder));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ConstructionInfoProvider));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (MostResolvableConstructorSelector));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerRequestLifeTime));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PropertySelector));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (AssemblyScanner));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ConstructorDependencySelector));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PropertyDependencySelector));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (CompositionRootTypeAttribute));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ConcreteTypeExtractor));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (CompositionRootExecutor));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (CompositionRootTypeExtractor));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (CachedTypeExtractor));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ImmutableList<>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (KeyValue<,>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ImmutableHashTree<,>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ImmutableHashTable<,>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerThreadScopeManagerProvider));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (Emitter));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (Instruction));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (Instruction<>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (GetInstanceDelegate));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ContainerOptions));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (CompositionRootAttributeExtractor));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerLogicalCallContextScopeManagerProvider));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (PerLogicalCallContextScopeManager));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (LogicalThreadStorage<>));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (DynamicMethod));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (ILGenerator));
      ConcreteTypeExtractor.InternalTypes.Add(typeof (LocalBuilder));
    }

    public Type[] Execute(Assembly assembly)
    {
      return assembly.DefinedTypes.Where<TypeInfo>((Func<TypeInfo, bool>) (info => ConcreteTypeExtractor.IsConcreteType(info))).Except<TypeInfo>(ConcreteTypeExtractor.InternalTypes.Select<Type, TypeInfo>((Func<Type, TypeInfo>) (i => i.GetTypeInfo()))).Cast<Type>().ToArray<Type>();
    }

    private static bool IsConcreteType(TypeInfo typeInfo)
    {
      return typeInfo.IsClass && !typeInfo.IsNestedPrivate && !typeInfo.IsAbstract && !object.Equals((object) typeInfo.Assembly, (object) typeof (string).GetTypeInfo().Assembly) && !ConcreteTypeExtractor.IsCompilerGenerated(typeInfo);
    }

    private static bool IsCompilerGenerated(TypeInfo typeInfo)
    {
      return typeInfo.IsDefined(typeof (CompilerGeneratedAttribute), false);
    }
  }
}
